<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Easy
  </div>
  <div>
   <h1 class="question_title">
    696. Count Binary Substrings
   </h1>
   <p>
    Give a string
    <code>
     s
    </code>
    , count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.
   </p>
   <p>
    Substrings that occur multiple times are counted the number of times they occur.
   </p>
   <p>
    <b>
     Example 1:
    </b>
    <br>
   </p>
   <pre>
<b>Input:</b> "00110011"
<b>Output:</b> 6
<b>Explanation:</b> There are 6 substrings that have equal number of consecutive 1's and 0's: "0011", "01", "1100", "10", "0011", and "01".
<br>Notice that some of these substrings repeat and are counted the number of times they occur.
<br>Also, "00110011" is not a valid substring because <b>all</b> the 0's (and 1's) are not grouped together.
</pre>
   <p>
    <b>
     Example 2:
    </b>
    <br>
   </p>
   <pre>
<b>Input:</b> "10101"
<b>Output:</b> 4
<b>Explanation:</b> There are 4 substrings: "10", "01", "10", "01" that have equal number of consecutive 1's and 0's.
</pre>
   <p>
    <b>
     Note:
    </b>
   </p>
   <li>
    <code>
     s.length
    </code>
    will be between 1 and 50,000.
   </li>
   <li>
    <code>
     s
    </code>
    will only consist of "0" or "1" characters.
   </li>
  </div>
  <div>
   <h1 class="question_title">
    696. 计数二进制子串
   </h1>
   <p>
    给定一个字符串&nbsp;
    <code>
     s
    </code>
    ，计算具有相同数量0和1的非空(连续)子字符串的数量，并且这些子字符串中的所有0和所有1都是组合在一起的。
   </p>
   <p>
    重复出现的子串要计算它们出现的次数。
   </p>
   <p>
    <strong>
     示例 1 :
    </strong>
   </p>
   <pre>
<strong>输入:</strong> "00110011"
<strong>输出:</strong> 6
<strong>解释:</strong> 有6个子串具有相同数量的连续1和0：&ldquo;0011&rdquo;，&ldquo;01&rdquo;，&ldquo;1100&rdquo;，&ldquo;10&rdquo;，&ldquo;0011&rdquo; 和 &ldquo;01&rdquo;。

请注意，一些重复出现的子串要计算它们出现的次数。

另外，&ldquo;00110011&rdquo;不是有效的子串，因为所有的0（和1）没有组合在一起。
</pre>
   <p>
    <strong>
     示例 2 :
    </strong>
   </p>
   <pre>
<strong>输入:</strong> "10101"
<strong>输出:</strong> 4
<strong>解释:</strong> 有4个子串：&ldquo;10&rdquo;，&ldquo;01&rdquo;，&ldquo;10&rdquo;，&ldquo;01&rdquo;，它们具有相同数量的连续1和0。
</pre>
   <p>
    <strong>
     注意：
    </strong>
   </p>
   <ul>
    <li>
     <code>
      s.length
     </code>
     &nbsp;在1到50,000之间。
    </li>
    <li>
     <code>
      s
     </code>
     &nbsp;只包含&ldquo;0&rdquo;或&ldquo;1&rdquo;字符。
    </li>
   </ul>
  </div>
 </body>
</html>